package com.xczl.demo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import com.xczl.demo.dao.UserLevelDao;
import com.xczl.demo.domain.GoodsCate;
import com.xczl.demo.domain.UserLevel;

@Service
@Transactional
public class UserLevelService {

	@Autowired
	private UserLevelDao userLevelDao;

	/**
	 * 添加商品分类
	 * 
	 * @param goodsCate
	 */
	public void add(UserLevel userLevel) {
		Assert.notNull(userLevel, "用户级别实体不存在");
		Assert.hasText(userLevel.getName(), "请填写级别名称");
		userLevelDao.insertUserLevel(userLevel);
	}

	/**
	 * 删除商品分类
	 * 
	 * @param id
	 */
	public void delete(int id) {
		userLevelDao.deleteUserLevel(id);
	}

	/**
	 * 更新商品分类
	 * 
	 * @param goodsCate
	 */
	public void update(UserLevel userLevel) {
		Assert.notNull(userLevel, "用户级别实体不存在");
		Assert.hasText(userLevel.getName(), "请填写级别名称");
		Assert.notNull(userLevel.getLevel(), "级别ID不存在");
		userLevelDao.updateUserLevel(userLevel);
	}
}
